Developer(s) | Spencer Tipping |
---|---|
Stable release | 3.1 / December 1, 2009 |
Operating system | Linux, Unix, Microsoft Windows, Mac OS, other operating systems with JRE implementations |
Type | Educational software |
License | MIT |
Website | http://spencertipping.com/ |
Cheloniidae Turtle Graphics is a simple turtle graphics programming library for Java. It is released under the MIT license. Distinguishing characteristics include an extension into three dimensions and the ability to create highly detailed and realistic drawings using colors, solids, antialiased rendering, and incidence angle shading.
Contents |
Cheloniidae is broken into two major pieces: The turtle, which executes drawing commands, and the turtle drawing window, which displays the output. Materially, these are analogous to a piece of chalk and a chalkboard, respectively. To create visible output, a turtle drawing window and a turtle must each be created, the turtle must be added to the window (these steps are handled automatically if your class inherits from SingleTurtleScene), and then drawing commands must be issued to the turtle. This code, for example, will produce a square:
import cheloniidae.*; import cheloniidae.frames.*; import static cheloniidae.frames.CoreCommands.*; public class Square extends SingleTurtleScene { public static void main (String[] args) {new Square ();} public TurtleCommand commands () { return repeat (4, move (100), turn (90)); } }
Internally, a turtle is represented by an object that produces line segments that are rendered by the window. Other types of turtles may also be used, including those which operate in non-Euclidean space; at present, however, no non-Euclidean turtles are included with the standard Cheloniidae distribution.
Multiple turtles can be added as well, allowing for two separate drawings to be produced simultaneously (2.1 code):
TurtleDrawingWindow w = new TurtleDrawingWindow (); Turtle t1 = new Turtle (); Turtle t2 = new Turtle (); w.add (t1); w.add (t2); w.setVisible (true); t2.turn (-45); for (int i = 0; i < 4; i++) { t1.move (100); t1.turn (90); t2.move (100); t2.turn (90); }